package com.ham.mud.classes;

import com.ham.mud.characters.Experience;
import com.ham.mud.characters.Stats;
import com.ham.mud.characters.Vitals;
import com.ham.mud.commands.skills.Skill;
import com.ham.mud.commands.spells.Spell;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by hlucas on Jun 28, 2011 at 11:43:36 AM
 */
public abstract class MudClass {
    public abstract String getName();
    public abstract Map<Integer, List<Skill>> getSkills();
    public List<Skill> getSkills(Experience experience) {
        int level = getLevel(experience);
        List<Skill> skills = new ArrayList<Skill>();
        Map<Integer, List<Skill>> skillsMap = getSkills();
        Set<Integer> keys = skillsMap.keySet();
        for(Integer key : keys) {
            if(key <= level) {
                skills.addAll(skillsMap.get(key));
            }
        }
        return skills;
    }

    public abstract Map<Integer, List<Spell>> getSpells();
    public List<Spell> getSpells(Experience experience) {
        int level = getLevel(experience);
        List<Spell> spells = new ArrayList<Spell>();
        Map<Integer, List<Spell>> spellsMap = getSpells();
        Set<Integer> keys = spellsMap.keySet();
        for(Integer key : keys) {
            if(key <= level) {
                spells.addAll(spellsMap.get(key));
            }
        }
        return spells;
    }

    public Vitals getVitals(Experience experience) {
        int level = getLevel(experience);
        int health = getStartingHealth() + getHealthPerLevel()*level;
        int mana = getStartingMana() + getManaPerLevel()*level;
        int move = 50 + getMovePerLevel()*level;
        return new Vitals(health,health,mana,mana,move,move);
    }

    public abstract Stats getBaseStats();
    public abstract Integer getStartingHealth();
    public abstract Integer getHealthPerLevel();
    public abstract Integer getStartingMana();
    public abstract Integer getManaPerLevel();
    public abstract Integer getMovePerLevel();
    public abstract int getLevel(Experience experience);
    public abstract int getToNextLevel(Experience experience);
}
